package implementor;

import org.opencv.core.Core;
import org.opencv.core.CvType;
import org.opencv.core.Mat;
import org.opencv.core.Scalar;
import org.opencv.imgproc.Imgproc;

public class SharpenFilter implements Filter {
    
    @Override
    public Mat apply(Mat image) {
        Mat result = new Mat();
        
        // 创建锐化卷积核
        Mat kernel = new Mat(3, 3, CvType.CV_32F, new Scalar(0));
        // 中心像素的权重
        kernel.put(0, 0, 0, -1, 0, -1, 5.2, -1, 0, -1, 0);
        // 应用卷积
        Imgproc.filter2D(image, result, -1, kernel);
        
        return result;
    }
    
    @Override
    public String getName() {
        return "Sharpen";
    }
}